home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1996 July: Mac OS SDK / Dev.CD Jul 96 SDK / Dev.CD Jul 96 SDK1.toast / Development Kits (Disc 1) / OpenDoc Development Framework / Developer University / DUProjects / DataSave / Sources / Commands.cpp < prev    next >
Encoding:
Text File  |  1996-03-29  |  1.9 KB  |  81 lines  |  [TEXT/CWIE]

  1. //    Release Version:    $ ODF 1 $
  2. //    Copyright:    (c) 1993 - 1996 by Apple Computer, Inc., all rights reserved.
  3.  
  4. //===============================================================
  5. #ifndef COMMANDS_H
  6. #include "Commands.h"        // CPizzaCommand
  7. #endif
  8.  
  9. #ifndef PIZZA_H
  10. #include "Pizza.h"            //  CPizza
  11. #endif
  12.  
  13. #ifndef CONTENT_H
  14. #include "Content.h"        // CDataSaveContent
  15. #endif
  16.  
  17. #ifndef FRAME_H
  18. #include "Frame.h"
  19. #endif
  20.  
  21. #ifndef DEFINES_K
  22. #include "Defines.k"                // command numbers
  23. #endif
  24.  
  25. //===============================================================
  26. #ifdef FW_BUILD_MAC
  27. #pragma segment DataCmd
  28. #endif
  29.  
  30. FW_DEFINE_AUTO(CPizzaCommand)
  31.  
  32. //===============================================================
  33. CPizzaCommand::CPizzaCommand(Environment* ev, 
  34.                              ODCommandID id, 
  35.                              FW_CFrame* frame, 
  36.                              CDataSaveContent* content,
  37.                              FW_CPoint position)
  38.   : FW_CCommand(ev, id, frame, FW_kCanUndo),
  39.       fContent(content),
  40.     fPizza(NULL)
  41. {
  42.     this->SetMenuStringsFromResource(ev, kUndoStringsID, 
  43.                             kUndoMakePizzaMsg, kRedoMakePizzaMsg);
  44.     FW_CPoint halfSize( FW_IntToFixed(15), FW_IntToFixed(15) );
  45.     FW_CRect bounds(position - halfSize, position + halfSize);
  46.     fPizza = new CPizza(bounds);
  47. }
  48.  
  49. //---------------------------------------------------------------
  50. CPizzaCommand::~CPizzaCommand()
  51. {
  52. }
  53.  
  54. //---------------------------------------------------------------
  55. void 
  56. CPizzaCommand::DoIt(Environment* ev)
  57. {
  58.     fContent->MyAddPizza(ev, fPizza);            // add a pizza 
  59. }
  60.  
  61. //---------------------------------------------------------------
  62. void 
  63. CPizzaCommand::UndoIt(Environment* ev)
  64. {
  65.     fContent->MyRemoveLastPizza(ev, fPizza);    // remove a pizza
  66. }
  67.  
  68. //---------------------------------------------------------------
  69. void 
  70. CPizzaCommand::RedoIt(Environment* ev)
  71. {
  72.     this->DoIt(ev);
  73. }
  74.  
  75. //---------------------------------------------------------------
  76. void 
  77. CPizzaCommand::FreeRedoState(Environment* ev)
  78. {
  79.     delete fPizza;
  80. }
  81.